import { objDeepCopy,getDateString } from "@/assets/js/common.js";
import commonObject from "@/assets/js/xm.js";
let Controller = {
	created() {
		this.init();
	},
	mounted() {
		
	},
	methods: {
		init() {
			this.getBarcodeDetail()
		},
		//获取barcode详情
		getBarcodeDetail(){

			let barcode = this.$route.query.barCode
			this.Model.barCode = barcode
			var apiTest = this.apiTest;
			this.$ajax({
					method: 'get',
					url:`${apiTest}/supplier/supplierGoods/barCode/detail/${barcode}`,
			    }).then((res)=>{
					var data = res.data;
					if(data.status == 200){
						const Model = this.Model
						this.detailDataFill(Model.propsInfoHeader_A,Model.propsInfoList_A,data.result)
						this.detailDataFill(Model.propsInfoHeader_B,Model.propsInfoList_B,data.result)
						this.detailDataFill(Model.wageInfoHeader,Model.wageInfos,data.result)
						this.detailDataFill(Model.checkInfosHeader,Model.checkPropInfos,data.result)
					}else{
			
					}
				});
		},
		//详情数据填充
		detailDataFill(tableKeyList,tabelDataBox,data){
			tabelDataBox=[]
			let tempObj={}
			tableKeyList.forEach(item=>{
				tempObj[item.prop]=data[item.prop]||''
			})
			tabelDataBox.push(tempObj)
		},
	},
	watch: {
		$route: {
			immediate: true,
			handler (newVal, oldVal) {
				if(newVal.name=='giveQualityBarcodeDetail'&&this.Model.propsInfoList_A.length){
					//重置数据
					this.Model.propsInfoList_A=[]
					this.Model.propsInfoList_B=[]
					this.Model.propsInfoList_C=[]
					this.getBarcodeDetail()
				}
			}
		}
	}
}
export default Controller;
